Skip to content

Conversation

@knowledgecode
Copy link
Owner

Summary

This PR introduces major enhancements to timezone handling and improves code organization:

  • Refactored timezone type definition: Separated TimeZone interface and helper functions into a new zone.ts file for better code organization
  • Consolidated timezone imports: Added a new date-and-time/timezone entry point allowing import of multiple timezones from a single module
  • IANA timezone name string support: The format() function now accepts IANA timezone name strings (e.g., 'Asia/Tokyo') in addition to TimeZone objects
  • Code quality improvements: Replaced logical OR operators with nullish coalescing operators for more precise null/undefined handling
  • Comprehensive tests: Added tests for new timezone features to ensure both import methods produce identical results
  • Version bump: Updated to v4.2.0 with latest dependencies

Changes Included

1. Refactor: Separate TimeZone type definition into zone.ts

  • Move TimeZone interface and helper functions to new zone.ts file
  • Update all imports across the codebase

2. Feat: Add consolidated timezone imports and IANA timezone name string support

  • Generate both individual timezone files and integrated timezone.ts file
  • Support IANA timezone name strings in format()
  • Add ./timezone export to package.json

3. Refactor: Use nullish coalescing operator and improve code quality

  • Improve null/undefined handling in formatter.ts
  • Use helper functions for better code clarity

4. Test: Add tests for new timezone features

  • Test consolidated timezone imports
  • Test IANA timezone name string support
  • Verify both methods produce identical results

5. Docs: Update documentation

  • Document the three methods for specifying timezones
  • Add migration guide for v4.2.0

6. Chore: Bump version to 4.2.0 and update dependencies

  • Update version to 4.2.0
  • Update development dependencies

Move TimeZone interface and helper functions from timezone.ts to a new
zone.ts file to improve code organization and prepare for adding
consolidated timezone imports feature.

This change does not affect the external API or functionality.
… support

Add two new ways to use timezones:

1. Consolidated imports: Import multiple timezones from a single module
   import { Tokyo, New_York } from 'date-and-time/timezone';

2. IANA timezone name strings: Use timezone names directly in format()
   format(date, 'YYYY-MM-DD HH:mm', { timeZone: 'Asia/Tokyo' });

The tools/timezone.ts script now generates both individual timezone files
and an integrated timezone.ts file for consolidated imports.

Note: The parse() function does not support IANA name strings, only
TimeZone objects and the "UTC" string.
Add comprehensive tests for:
- Consolidated timezone imports from 'date-and-time/timezone'
- IANA timezone name string support in format()
- Ensure both import methods produce identical results
Update all documentation to explain the three methods for specifying
timezones:

1. Individual imports (date-and-time/timezones/Asia/Tokyo)
2. Consolidated imports (date-and-time/timezone)
3. IANA timezone name strings (format only)

Add migration guide for v4.2.0 with detailed examples and usage notes.
Update version to 4.2.0 to reflect new timezone features.
Update development dependencies to their latest versions.
@knowledgecode knowledgecode merged commit c54dc6e into master Jan 18, 2026
4 checks passed
@knowledgecode knowledgecode deleted the develop branch January 18, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants